define(
	[
		'require',
		'broada/base/text!./template.hbs'
	],
	function (require) {
		"use strict";
		var tpl = require('broada/base/text!./template.hbs');

		var Component = Ember.Component.extend({
			layout: Ember.HTMLBars.compile(tpl),
			didInsertElement: function(){

				 var ctrl = this.get("controller");
				 var view = this;
		         var $viewRoot = this.$(),
		         	 returnField = {};
		         $viewRoot.find(".alarm-time-day span").on("click",function(){
		         	 $viewRoot.find(".alarm-time-day div").removeClass("active");
		         	var week = $(this).html();
		         	if($(this).hasClass("active")){
		         		$(this).removeClass("active");
		         		returnField = view.deleteWeek(week,returnField);
		         	}else{
		         		$(this).addClass("active");
		         		$(".alarm-time-hours span").removeClass("active");
		         		returnField = view.addWeek(week,returnField);
		         	};
		         	
		         	
		         	ctrl.sendAction("dateSelect",returnField);
		         });

		         $viewRoot.find(".alarm-time-day div").on("click",function(){
		         	if($(this).hasClass("active")){
		         		$(this).removeClass("active");
		         		returnField = {};
		         	}else{
		         		$(this).addClass("active");
	         			ctrl.set("isAll",false);
	         			$(".alarm-time-hours span").addClass("active");
		         		$viewRoot.find(".alarm-time-day span").removeClass("active");
		         		// returnField = {"1":"",};
		         	};
		         	ctrl.sendAction("dateSelect",returnField);
		         });
		         $viewRoot.find(".alarm-time-hours span").on("click",function(){
		         	if($(this).hasClass("active")){
		         		$(this).removeClass("active");
		         		ctrl.set("isAll",true);
		         		
		         	}else{
		         		$(this).addClass("active");
		         		ctrl.set("isAll",false);
		         	};
		         });
		       $viewRoot.find(".alarm-time-hours span").addClass("active");
		       ctrl.set("isAll",false);
			},
			//根据week来筛选赋值
			addWeek: function(week,returnField){
				switch(week){
	         		case "一":
	         			returnField["1"] = ["00:00:00-24:00:00"];
	         			this.set("isAll",true);
	         		break;
	         		case "二":
	         			returnField["2"] = ["00:00:00-24:00:00"];
	         			this.set("isAll",true);
	         		break;
	         		case "三":
	         			returnField["3"] = ["00:00:00-24:00:00"];
	         			this.set("isAll",true);
	         		break;
	         		case "四":
	         			returnField["4"] = ["00:00:00-24:00:00"];
	         			this.set("isAll",true);
	         		break;
	         		case "五":
	         			returnField["5"] = ["00:00:00-24:00:00"];
	         			this.set("isAll",true);
	         		break;
	         		case "六":
	         			returnField["6"] = ["00:00:00-24:00:00"];
	         			this.set("isAll",true);
	         		break;
	         		case "日":
	         			returnField["7"] = ["00:00:00-24:00:00"];
	         			this.set("isAll",true);
	         		break;
	         	};
	         	return returnField;
			},
			//根据week来筛选删除值
			deleteWeek: function(week,returnField){
				switch(week){
	         		case "一":
	         			delete(returnField["1"]); 
	         		break;
	         		case "二":
	         			delete(returnField["2"]); 
	         		break;
	         		case "三":
	         			delete(returnField["3"]); 
	         		break;
	         		case "四":
	         			delete(returnField["4"]); 
	         		break;
	         		case "五":
	         			delete(returnField["5"]); 
	         		break;
	         		case "六":
	         			delete(returnField["6"]); 
	         		break;
	         		case "日":
	         			delete(returnField["7"]); 
	         		break;
	         	};
	         	return returnField;
			}
		});

		return Component;
	}
);